1 : <?php
2 : /*--------------------------------------------------------------------------+
3 : This file is part of eStudy.
4 : courses/classes/class.estudycourse.inc.php
5 : - Modulgruppe: Kurse
6 : - Beschreibung: Klasse zur Repraesentation eines Kurses.
7 : - Version: 0.1, 10/01/06
8 : - Autor(en): Christoph Gockel <christoph.gockel@mni.fh-giessen.de>
9 : +---------------------------------------------------------------------------+
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or any later version.
14 : +---------------------------------------------------------------------------+
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 : You should have received a copy of the GNU General Public License
20 : along with this program; if not, write to the Free Software
21 : Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 : */
23 1 : require_once "class.tree.inc.php";
24 :
25 : class EStudyCourse
26 1 : {
27 : /** Die ID des Kurses */
28 : var $_id;
29 : /** Der Kursname */
30 : var $_name;
31 : /** Der Kursname in kurz */
32 : var $_shortname;
33 : /** In welchem Semester ist der Kurs? */
34 : var $_semester;
35 : /** Wann beginnt der Kurs? */
36 : var $_opendate;
37 : /** Wann endet der Kurs? */
38 : var $_closedate;
39 : /** Module? */
40 : var $_modules;
41 : /** ??? */
42 : var $_assrights;
43 : /** Maximale Teilnehmerzahl */
44 : var $_maxstudents;
45 : /** Anmeldepasswort */
46 : var $_regpass;
47 : /** Gibt es eine Warteliste? */
48 : var $_usewaitinglist;
49 : /** Weiterer Informationstext */
50 : var $_info;
51 : /** Mailflag? */
52 : var $_mailflag;
53 : /** Kurs offen od. geschlossen? */
54 : var $_closed;
55 : /** Der Indikator */
56 : var $_indikator;
57 :
58 : var $_db;
59 :
60 : /**
61 : * Legt ein Objekt des Kurses mit der Nummer $id an.
62 : * @param $id Die ID des Kurses
63 : */
64 : function EStudyCourse($id)
65 : {
66 0 : global $db;
67 0 : $this->_db = $db;
68 0 : $row= $this->_db->get_row("SELECT * FROM courses WHERE ID='$id'", ARRAY_A);
69 :
70 0 : $this->_id = $row['ID'];
71 0 : $this->_name = $row['Name'];
72 0 : $this->_shortname = $row['ShortName'];
73 0 : $this->_semester = $row['Semester'];
74 0 : $this->_opendate = $row['OpenDate'];
75 0 : $this->_closedate = $row['CloseDate'];
76 0 : $this->_modules = $row['Modules'];
77 0 : $this->_assrights = $row['AssRights'];
78 0 : $this->_maxstudents = $row['MaxStudents'];
79 0 : $this->_regpass = $row['RegPass'];
80 0 : $this->_usewaitinglist = ($row['UseWaitinglist'] == 0) ? false : true;
81 0 : $this->_info = $row['Info'];
82 : //$this->_mailflag = ($row['mailflag'] == 0) ? false : true;
83 0 : $this->_closed = ($row['closed'] == 0) ? false : true;
84 0 : $this->_indikator = $row['indikator'];
85 0 : }
86 :
87 : function __toString()
88 : {
89 0 : return $this->getName();
90 : }
91 :
92 : /**
93 : * Gibt die ID des Kurses zurueck.
94 : * @return Die Kurs-ID
95 : */
96 : function getId()
97 : {
98 0 : return (int)$this->_id;
99 : }
100 :
101 : /**
102 : * Gibt den (vollstaendigen) Kursnamen zurueck.
103 : * @return Der Kursname
104 : */
105 : function getName()
106 : {
107 0 : return $this->_name;
108 : }
109 :
110 : /**
111 : * Gibt das Kurs-Kuerzel zurueck.
112 : * @return Das Kurs-Kuerzel
113 : */
114 : function getShortName()
115 : {
116 0 : return $this->_shortname;
117 : }
118 :
119 : /**
120 : * Gibt das Semester des Kurses zurueck, z.B. in der Darstellung "WS 05/06"
121 : * @return Das Semester des Kurses (als String)
122 : */
123 : function getSemester()
124 : {
125 0 : return $this->_semester;
126 : }
127 :
128 : /**
129 : * Gibt das Eroeffnungsdatum des Kurses zurueck.
130 : * @return Das Eroeffnungsdatum
131 : */
132 : function getOpenDate()
133 : {
134 0 : return $this->_opendate;
135 : }
136 :
137 : /**
138 : * Gibt das Enddatum des Kurses zurueck.
139 : * @return Das Enddatum
140 : */
141 : function getCloseDate()
142 : {
143 0 : return $this->_closedate;
144 : }
145 :
146 : /**
147 : * Gibt die Module des Kurses zurueck (??)
148 : * @return Die Module
149 : */
150 : function getModules()
151 : {
152 0 : return $this->_modules;
153 : }
154 :
155 : /**
156 : * ???
157 : */
158 : function getAssRights()
159 : {
160 0 : return $this->_assrights;
161 : }
162 :
163 : /**
164 : * Liefert die maximale Anzahl der Teilnehmer.
165 : * @return Maximale Teilnehmeranzahl
166 : */
167 : function getMaxStudents()
168 : {
169 0 : return $this->_maxstudents;
170 : }
171 :
172 : /**
173 : * Gibt das Anmeldepasswort zurueck.
174 : * @return Das Anmeldepasswort des Kurses
175 : */
176 : function getRegPass()
177 : {
178 0 : return $this->_regpass;
179 : }
180 :
181 : /**
182 : * Liefert die Information ob der Kurs ueber eine Warteliste verfuegt.
183 : * @return true od. false, jenachdem ob eine Warteliste genutzt wird oder nicht
184 : */
185 : function usesWaitingList()
186 : {
187 0 : return $this->_usewaitinglist;
188 : }
189 :
190 : /**
191 : * Gibt den Beschreibungstext des Kurses zurueck.
192 : * @return Die Kursbeschreibung
193 : */
194 : function getInfo()
195 : {
196 0 : return $this->_info;
197 : }
198 :
199 : /**
200 : *
201 : */
202 : function getMailflag()
203 : {
204 0 : return $this->_mailflag;
205 : }
206 :
207 : /**
208 : * Liefert den Status des Kurses (offen od. geschlossen).
209 : * @return true od. false, jenachdem ob der Kurs offen oder geschlossen ist
210 : */
211 : function isClosed()
212 : {
213 0 : return $this->_closed;
214 : }
215 :
216 : /**
217 : *
218 : */
219 : function getIndikator()
220 : {
221 0 : return $this->_indikator;
222 : }
223 :
224 : static function is_mSC_used_in_open_course($modulShortCut)
225 : {
226 0 : global $db, $EZSQL_ERROR;
227 :
228 0 : $query = "SELECT ID FROM courses WHERE modulShortCut='$modulShortCut'";
229 0 : $errorCount = count($EZSQL_ERROR);
230 0 : $liste = $db->get_results($query, ARRAY_N);
231 0 : if (count($EZSQL_ERROR) > $errorCount)
232 0 : Output :: errorMessage("Fataler Fehler beim Datenbankzugriff aufgetreten!", 1, false, true);
233 : else
234 : if ($liste)
235 0 : {
236 : //Falls ein offener Kurs mit dem selben Modulkürzel existiert, wird false zurück gegeben
237 0 : foreach ($liste as $course)
238 0 : $ecourse = new EStudyCourse($course[0]);
239 0 : if (!$ecourse->isClosed())
240 0 : return true;
241 0 : }
242 :
243 0 : return false;
244 : }
245 : }
246 :
247 : ?>
|